<template>
  <div>
    <en-table-layout
      toolbar
      pagination
      ref="tableLayout"
      :height="tableHeight"
      :loading="loading"
      :tableData="tableData"
      :selectionChange="selectionChange">
      <div slot="toolbar" class="inner-toolbar">
        <div class="toolbar-btns">
          <el-button @click="copyBatchGoods" type="primary">复制商品</el-button>
          <el-button @click="publishGoods" type="primary">发布商品</el-button>
          <el-button @click="gotoRecycle"  type="primary">回收站</el-button>
          <el-button @click="openAbnormalImport"  type="primary">批量修改商品库存</el-button>
        </div>
        <div class="top-search">
            <!--商品状态 上架 下架-->
            <div class="conditions">
              <span>商品状态：</span>
              <el-select
                class="choose-machine"
                v-model="params.market_enable"
                placeholder="请选择商品状态"
                @change="changeGoodsStatus"
                clearable>
                <el-option
                  v-for="item in goodsStatusList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"></el-option>
              </el-select>
            </div>
            <!--商品类型-->
            <div v-if="parseInt(shopInfo.self_operated) === 1" class="conditions">
              <span>商品类型：</span>
              <el-select
                class="choose-machine"
                v-model="params.goods_type"
                placeholder="请选择商品类型"
                @change="changeGoodsType"
                clearable>
                <el-option key="NORMAL" label="正常商品" value="NORMAL"/>
                <el-option key="POINT" label="积分商品" value="POINT"/>
              </el-select>
            </div>
            <!--商品分组 获取分组列表-->
            <!-- <el-button @click="publishGoodsOld">发布商品(旧版)</el-button> -->
          <en-table-search
            @search="searchEvent"
            @advancedSearch="advancedSearchEvent"
            advanced
            advancedWidth="450"
            placeholder="请输入商品名称">
            <template slot="advanced-content">
              <el-form ref="advancedForm" class="advancedForm" :model="advancedForm" label-width="78px" :rules="advancedFormRules">
                <el-form-item label="商品ID" prop="goods_ids">
                  <el-input v-model="advancedForm.goods_ids" placeholder="请输入ID，多个ID用“，”分隔" clearable></el-input>
                </el-form-item>
                <el-form-item label="店铺分组">
                  <en-category-picker class="choose-machine" size="mini" @changed="changeGoodsCateGory" clearable/>
                </el-form-item>
                <el-form-item label="供应商">
                  <el-input v-model="advancedForm.supplier_name" placeholder="请输入供应商名称" clearable></el-input>
                </el-form-item>
              </el-form>
            </template>
          </en-table-search>
        </div>
        <!-- <div class="toolbar-search">
          <en-table-search @search="searchEvent" placeholder="请输入商品名称"/>
        </div> -->
      </div>
      <template slot="table-columns">
        <el-table-column type="selection" width="50" fixed/>
        <el-table-column label="图片" width="80">
          <template slot-scope="scope">
            <a :href="`${MixinBuyerDomain}/goods/${scope.row.goods_id}`" target="_blank">
              <img :src="scope.row.thumbnail" class="goods-image"/>
            </a>
          </template>
        </el-table-column>
	      <el-table-column label="商品ID" prop="goods_id" width="150"/>
        <el-table-column label="商品名称" min-width="200">
          <div slot-scope="scope" style="text-align:left">
            <a :href="`${MixinBuyerDomain}/goods/${scope.row.goods_id}`" target="_blank" style="color: #00a2d4;">
              <span>{{ scope.row.goods_name }}</span><br>
              <span v-if="scope.row.supplier_name" class="goodsSource">[來源：{{scope.row.supplier_name}}]</span>
            </a>
          </div>
        </el-table-column>
        <el-table-column label="快递到家" prop="is_global" min-width="100">
          <template slot-scope="scope">
            <span class="greenText" :class="{'redText': scope.row.is_global===0}">{{scope.row.is_global==1?'是':'否'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="站点自提" prop="is_self" min-width="100">
          <template slot-scope="scope">
            <span class="greenText" :class="{'redText': scope.row.is_self===0}">{{scope.row.is_self==1?'是':'否'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="商品分组" prop="shop_cat_ids" min-width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="cat-show-box">
              <div class="cat-show-row">
                <div class="cat-show-item"
                  v-for="(catItem, catIndex) in scope.row.shop_cat_item_list"
                  :key="catIndex"
                  v-html="catItem.cat_path_name">
                </div>
              </div>
              <div class="cat-edit">
                <span class="table-edit el-icon-edit-outline" @click="showCatDialog(scope.row, scope.$index)"></span>
              </div>
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column label="供应商" prop="supplier_name" min-width="100"></el-table-column> -->
        <el-table-column label="价格" width="120">
          <template slot-scope="scope">{{ scope.row.price | unitPrice('￥') }}</template>
        </el-table-column>
        <el-table-column label="库存" width="120">
          <template slot-scope="scope">{{ scope.row.quantity }}件</template>
        </el-table-column>
        <el-table-column label="可用库存" width="120">
          <template slot-scope="scope">{{ scope.row.enable_quantity }}件</template>
        </el-table-column>
        <el-table-column  label="状态" width="120">
          <template slot-scope="scope">
            <span>{{ scope.row | marketStatus }}</span>
            <div class="under-reason" v-if="scope.row.market_enable === 0" @click="showUnderReason(scope.row)">(下架原因)</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="380" style="text-align: left;">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="success"
              @click="handleEditGoods(scope.row)">编辑</el-button>
            <el-button
              size="mini"
              type="danger"
              v-if="scope.row.market_enable === 0"
              @click="handleDeleteGoods(scope.row)">删除</el-button>
            <el-button
              size="mini"
              type="danger"
              v-if="scope.row.market_enable === 1"
              @click="handleUnderGoods(scope.row)">下架</el-button>
            <el-button
              type="primary"
              size="mini"
              @click="handleStockGoods(scope.row)">库存</el-button>
            <el-button
              v-if="distributionSet"
              type="primary"
              size="mini"
              @click="handleRebate(scope.row)">分销</el-button>
            <el-button
              v-if="distributionSet"
              type="primary"
              size="mini"
              @click="handleUpdatePriceDialog(scope.row)">价格</el-button>
          </template>
        </el-table-column>
      </template>
      <div slot="pagination-toolbar">
        <el-checkbox
          class="pagination-check-all"
          :indeterminate="tableIsIndeterminate"
          v-model="tableCheckAll"
          @change="checkAllChange">全选</el-checkbox>
          <span @click="batchGoods(0)" class="batch_f">批量上架</span>
          <span @click="batchGoods(1)" class="batch_f">批量下架</span>
          <span @click="setBatchGoods()" class="batch_f">批量设置佣金</span>
          <span @click="setBatchUpdateShopCat()" class="batch_f">批量设置分组</span>
      </div>
      <el-pagination
        slot="pagination"
        v-if="pageData"
        @size-change="handlePageSizeChange"
        @current-change="handlePageCurrentChange"
        :current-page="pageData.page_no"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageData.page_size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageData.data_total">
      </el-pagination>
    </en-table-layout>
    <!--批量设置佣金-->
    <el-dialog title="批量设置分销佣金" :visible.sync="isShowSetbate" width="400px">
      <el-form :model="setbateData" label-width="100px" :rules="setRules" ref="setbateData" status-icon>
        <el-form-item label="已选中" class="choosedPromos">
          <span>{{selectedDatas.length}}  条商品进行批量设置佣金</span>
        </el-form-item>
        <el-form-item label="一级分销佣金" prop="grade1Rebate">
          <el-input v-model="setbateData.grade1Rebate">
            <template slot="append">%</template>
          </el-input>
        </el-form-item>
        <el-form-item label="二级分销佣金" prop="grade2Rebate">
          <el-input v-model="setbateData.grade2Rebate">
            <template slot="append">%</template>
          </el-input>
        </el-form-item>
        <el-form-item label="会员邀请佣金" prop="inviterRate">
          <el-input v-model="setbateData.inviterRate">
            <template slot="append">%</template>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="batDataSet('setbateData')">保存</el-button>
          <el-button type="" @click="cansleBatSet()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!--库存编辑-->
    <el-dialog title="库存编辑" :visible.sync="goodsStockshow" width="800px" class="pop-sku">
      <div align="center">
        <el-form :model="goodsStockData" ref="goodsStockData" v-if="goodsStocknums === 1" style="width: 50%;" label-width="100px" :rules="rules">
          <el-form-item label="库存" prop="quantity" >
            <el-input  v-model="goodsStockData.quantity" />
          </el-form-item>
          <el-form-item label="待发货数" >
            <el-input v-model="goodsStockData.deliver_goods_quantity"  disabled />
          </el-form-item>
        </el-form>
        <en-table-layout
          :tableData="goodsStockData"
          :loading="loading"
          border
          v-if="goodsStocknums > 1"
          :span-method="arraySpanMethod"
          :stripe="false">
          <template slot="table-columns">
            <el-table-column
              v-for="(item, index) in goodsStockTitle"
              v-show="item.prop !== 'sku_id'"
              :label="item.label"
              :key="index">
              <template slot-scope="scope">
                <el-input v-if="item.prop === 'quantity'" @blur="checkQuantity(scope.row.quantity)" v-model="scope.row.quantity"/>
                <span v-if="item.prop !== 'quantity'" >{{ scope.row[item.prop] }}</span>
              </template>
            </el-table-column>
          </template>
        </en-table-layout>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="reserveStockGoods(1)">刷 新</el-button>
        <el-button @click="goodsStockshow = false">取 消</el-button>
        <el-button type="primary" @click="reserveStockGoods(0)">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 批量导入 -->
    <el-dialog title="批量修改商品库存" width="450px" :visible.sync="importDialog">
      <el-form
        ref="updateImportForm"
        label-width="100px"
        size="small"
        :model="importForm"
        :rules="importFormRules"
        >
        <el-button size="mini" type="primary" >
          <a href="https://egale-shop.oss-cn-hangzhou.aliyuncs.com/excel/%E6%89%B9%E9%87%8F%E4%BF%AE%E6%94%B9%E5%BA%93%E5%AD%98.xlsx">下载模板</a>
        </el-button>
        <el-form-item prop="uploadFile" label-width="0">
          <div class="upload">
            <div class="el-upload__tip" slot="tip">只能上传 .xlsx, .xls文件</div>
              <el-upload
                v-model="importForm.uploadFile"
                :limit="1"
                drag
                ref="upload"
                action="#"
                :http-request="excelLoadShow"
                :on-change="onUploadChange"
                >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
              </el-upload>
            </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary"  @click="submitFileForm('updateImportForm')">确 定</el-button>
        <el-button size="small" @click="handleCancel('updateImportForm')">取 消</el-button>
      </div>
    </el-dialog>
    <!--下架原因-->
    <el-dialog title="下架原因" :visible.sync="isShowUnderReason" width="17%" >
      <div align="center">{{ under_reason }}</div>
    </el-dialog>
    <!--分销返利-->
    <el-dialog title="分销返利" :visible.sync="isShowDisRebate" width="24%">
      <el-form :model="disRebateData" label-width="100px" :rules="disRules" ref="disRebateData" status-icon>
        <el-form-item label="1级返利" prop="grade1Rebate">
          <el-input v-model="disRebateData.grade1Rebate">
            <template slot="append">%</template>
          </el-input>
        </el-form-item>
        <el-form-item label="2级返利" prop="grade2Rebate">
          <el-input v-model="disRebateData.grade2Rebate">
            <template slot="append">%</template>
          </el-input>
        </el-form-item>
        <el-form-item label="邀请佣金" prop="inviter_rate">
          <el-input v-model="disRebateData.inviter_rate">
            <template slot="append">%</template>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="reserveDisSet('disRebateData')">保存</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!--修改价格-->
    <el-dialog title="修改价格" :visible.sync="updatePriceDialog" width="35%" class="price-sku">
      <div align="center">
        <el-form :model="updatePriceData" ref="updatePriceData" v-if="skuNums === 1" style="width: 50%;" label-width="100px" :rules="rules">
          <el-form-item label="成本价" prop="quantity" >
            <el-input  v-model="updatePriceData.cost" />
          </el-form-item>
          <el-form-item label="售价" >
            <el-input v-model="updatePriceData.price" />
          </el-form-item>
        </el-form>
        <en-table-layout
          :tableData="updatePriceData"
          :loading="loading"
          border
          v-if="skuNums > 1"
          :span-method="arraySpanMethodPrice"
          :stripe="false">
          <template slot="table-columns">
            <el-table-column
              v-for="(item, index) in updatePriceTitle"
              v-show="item.prop !== 'sku_id'"
              :label="item.label"
              :key="index">
              <template slot-scope="scope">
                <span v-if="item.prop === 'spec_value'" :data-str="scope.row.spec_value">{{ scope.row.spec_value }}</span>
                <el-input v-if="item.prop === 'cost'" @blur="checkQuantity(scope.row.cost)" v-model="scope.row.cost"/>
                <el-input v-if="item.prop === 'price'" @blur="checkQuantity(scope.row.price)" v-model="scope.row.price"/>
              </template>
            </el-table-column>
          </template>
        </en-table-layout>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveBatch()">保 存</el-button>
        <el-button @click="updatePriceDialog = false">取 消</el-button>
      </div>
    </el-dialog>
    
    <!--商品分组-->
    <el-dialog
      width="420px"
      title="修改商品分组"
      class="cat-dialog"
      v-loading="dialogLoading"
      :visible.sync="catDialog">
      <el-form ref="catForm" :model="catForm" label-width="80px">
        <!-- <el-form-item v-show="false" prop="goods_id">
          <el-input type="hidden" v-model="catForm.goods_id"></el-input>
        </el-form-item> -->
        <el-form-item label="商品分组" required>
          <el-form-item
            v-for="(catItem, index) in catForm.shop_cat_ids"
            :key="index"
            :prop="`shop_cat_ids.${index}.shop_cat_id`">
            <en-category-picker
              clearable
              :defaultVal="catItem.shop_cat_id"
              @changed="changeShopCat($event, index)"/>
            <el-tooltip class="item" effect="dark" content="删除分组" placement="top">
              <el-button
                v-if="catForm.shop_cat_ids.length>1"
                type="danger"
                icon="el-icon-delete"
                plain
                circle
                @click="deleteCat(index)"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="添加分组" placement="top">
              <el-button
                v-if="catForm.shop_cat_ids.length===index+1"
                type="success"
                icon="el-icon-plus"
                plain
                circle
                @click="addCat()"></el-button>
            </el-tooltip>
          </el-form-item>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="catDialog = false">取 消</el-button>
        <el-button v-loading="dialogLoading" type="primary" @click="catSubmit()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import * as API_goods from '@/api/goods'
  import { CategoryPicker } from '@/components'
  import { RegExp } from '~/ui-utils'
  let multipleSelection = []
  export default {
    name: 'goodsList',
    components: {
      [CategoryPicker.name]: CategoryPicker
    },
    data() {
      const checkQuantity = (rule, value, callback) => {
        if (!value && value !== 0) {
          return callback(new Error('库存不能为空'))
        }
        setTimeout(() => {
          if (!/^[0-9]\d*$/.test(value)) {
            callback(new Error('请输入整数'))
          } else if (!(parseInt(value) >= 0 && parseInt(value) <= 99999999)) {
            callback(new Error('请输入0 - 99999999之间的正整数'))
          } else {
            callback()
          }
        }, 500)
      }
      const checkMoney = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('返利金额不能为空'))
        }
        setTimeout(() => {
          if (!RegExp.money.test(value)) {
            callback(new Error('请输入正确的金额'))
          } else if (parseFloat(value) < 0 || parseFloat(value) > 99999999) {
            callback(new Error('请输入0~99999999之间的金额'))
          } else {
            callback()
          }
        }, 500)
      }
      const checkSetMoney = (rule, value, callback) => {
        setTimeout(() => {
          if (!RegExp.money.test(value)) {
            callback(new Error('请输入正确的金额'))
          } else if (parseFloat(value) < 0 || parseFloat(value) > 99999999) {
            callback(new Error('请输入0~99999999之间的金额'))
          } else {
            callback()
          }
        }, 500)
      }
      const isNum = (rule, value, callback) => {
        const age= /^[0-9]*$/
        if (!age.test(value)) {
          callback(new Error('商品ID只能为数字'))
        } else {
          callback()
        }
      }

      return {
        /** table高度 */
        tableHeight: 700,

        /** 列表loading状态 */
        loading: false,
        dialogLoading: false,
        catDialog: false,
        catForm: {
          update_type: 1,
          goods_id: [],
          shop_cat_ids: []
        },
        catFormType: 'single',
        editCatRow: undefined,

        /** 列表参数 */
        params: {
          page_no: 1,
          page_size: 50,
          // 商品类型 默认为'' NORMAL 正常商品 POINT 积分商品
          goods_type: '',
          ...this.$route.query
        },
        advancedForm: {
          shop_cat_path: '',
          goods_ids: undefined,
          supplier_name: undefined
        },
        advancedFormRules: {
          goods_ids: [
            { required: false, message: '请输入年龄', trigger: 'blur' },
            { pattern: /^[0-9,，,\n]+$/, message: '请输入正确的ID，多个ID用","分隔', trigger: 'blur' }
          ]
        },
        /** 列表数据 */
        tableData: [],

        /** 列表分页数据 */
        pageData: [],

        /** 商品状态列表 */
        goodsStatusList: [
          { value: 0, label: '未出售（已下架）' },
          { value: 1, label: '出售中（已上架）' }
        ],
        tableCheckAll: false,
        tableIsIndeterminate: false,

        /** 当前商品分组*/
        categoryId: '',

        /** 当前商品id*/
        goodsId: '',

        /** 商品库存显示*/
        goodsStockshow: false,
        // 批量导入商品库存
        importDialog: false,
        files: undefined,
        importForm: {
          uploadFile: undefined
        },
        importFormRules: {
          uploadFile: [
            {
              required: true,
              message: '上传文件不能为空',
              trigger: 'blur'
            }
          ]
        },

        /** 是否显示下架原因 */
        isShowUnderReason: false,

        /** 下架原因 */
        under_reason: '',

        /** 库存商品数量*/
        goodsStocknums: 0,
        /** 商品库存列表数据*/
        goodsStockData: null,
        /** 商品库存列表表头数据 */
        goodsStockTitle: [],

        /** 修改价格弹窗 */
        updatePriceDialog: false,
        updatePriceData: null,
        updatePriceTitle: [],
        /** 库存商品数量*/
        skuNums: 0,

        /** 要合并的列的位置数组 */
        concactArray: [],
        /** 要合并的列的位置数组 */
        concactPriceArray: [],

        /** 校验规则 */
        rules: {
          quantity: [
            { validator: checkQuantity, trigger: 'blur' }
          ]
        },

        /** 店铺信息 */
        shopInfo: this.$store.getters.shopInfo,

        /** 分销设置是否开启 1开启 0关闭 */
        distributionSet: 0,

        /** 是否显示分销返利弹框 */
        isShowDisRebate: false,

        /** 是否显示批量设置分销佣金弹框 */
        isShowSetbate: false,

        /** 分销返利数据 */
        disRebateData: {
          /** 商品id */
          goods_id: 0,

          /** 1级返利 */
          grade1Rebate: 0,

          /** 2级返利 */
          grade2Rebate: 0,

          /** 邀请佣金 */
          inviter_rate: 0
        },
        /** 批量设置分销佣金 */
        setbateData: {
          /** 1级返利 */
          grade1Rebate: 0,

          /** 2级返利 */
          grade2Rebate: 0,

          /** 邀请佣金 */
          inviterRate: 0
        },
        selectedDatas: [],

        /** 分销返利校验规则 */
        disRules: {
          grade1Rebate: [
            { required: true, message: '1级返利金额不能为空', trigger: 'blur' },
            { validator: checkMoney, trigger: 'blur' }
          ],
          grade2Rebate: [
            { required: true, message: '2级返利金额不能为空', trigger: 'blur' },
            { validator: checkMoney, trigger: 'blur' }
          ],
          inviter_rate: [
            { required: true, message: '邀请佣金金额不能为空', trigger: 'blur' },
            { validator: checkMoney, trigger: 'blur' }
          ]
        },

        /** 分销返利校验规则 */
        setRules: {
          grade1Rebate: [
            { required: false, message: '1级返利金额不能为空', trigger: 'blur' },
            { validator: checkSetMoney, trigger: 'blur' }
          ],
          grade2Rebate: [
            { required: false, message: '2级返利金额不能为空', trigger: 'blur' },
            { validator: checkSetMoney, trigger: 'blur' }
          ],
          inviterRate: [
            { required: false, message: '邀请佣金金额不能为空', trigger: 'blur' },
            { validator: checkSetMoney, trigger: 'blur' }
          ]
        }
      }
    },
    filters: {
      /** 销售状态格式化 */
      marketStatus(row) {
        switch (row.is_auth) {
          case 0 : return row.market_enable === 1 ? '待审核' : '已下架'
          case 1 : return row.market_enable === 1 ? '售卖中' : '已下架'
          case 2 : return row.market_enable === 1 ? '审核拒绝' : '已下架'
        }
      }
    },
    beforeRouteLeave(to, from, next) {
      let position = document.getElementsByClassName('el-table__body-wrapper')[0].scrollTop  //记录离开页面的位置
      if (position == null) position = 0
      this.$store.dispatch('changeRecruitScrollY', position) //离开路由时把位置存起来
      if ( to.name === 'goodPublish') {
        this.$store.dispatch('saveSearchGoodsName', this.params) //离开路由时把查询条件保存
      }
      next ()
    },
    beforeRouteEnter(to, from, next) {
      if (from.name === 'goodPublish') {
        next( vm => {
          vm.params.keyword = vm.$store.state.app.searchGoodsName.keyword
          vm.searchEvent(vm.params.keyword)
        })
      } else {
        next( vm => {
          vm.params.keyword = ''
          vm.searchEvent(vm.params.keyword)
        })
      }
    },
    activated() {
      this.params = { ...this.params, ...this.$route.query };
      this.params.market_enable && (this.params.market_enable = parseInt(this.params.market_enable));
      this.GET_GoodsList();
      this.getDistributionSet();
    },
    mounted() {
      this.computClient();
      // 2、挂载 reisze 事件 → 屏幕缩放时监听宽高变化
      window.onresize = () => {
        return (() => {
          this.computClient();
        })()
      }
      this.GET_GoodsList();
      this.getDistributionSet();
    },
    methods: {
      resetCopyright() {
        let recruitScrollY = this.$store.state.app.recruitScrollY
        document.getElementsByClassName('el-table__body-wrapper')[0].scrollTo(0, recruitScrollY)
      },
      /*
        * @date 2019-05-27
        * @author wolfMan
        * @description {计算窗口宽高}
      */
      computClient() {
        this.$nextTick(() => {
          const _clientHeight = document.documentElement.clientHeight;
          this.tableHeight = _clientHeight - 80 - 44 - 20 - 70 - 44;
        })
      },
      /** 获取选中项*/
      selectionChange(val) {
        const _count = val.length;
        const _tableLength = this.tableData.length;
        this.selectedDatas = val;
        this.tableIsIndeterminate = _count > 0 && _count < _tableLength;
        this.tableCheckAll = _count === _tableLength;
        if (_count === 0) {
          this.tableCheckAll = false;
        } else if (_count === _tableLength) {
          this.tableCheckAll = true;
        }
        this.multipleSelection = val;
      },
      /** 全选*/
      checkAllChange() {
        this.$refs['tableLayout'].$refs['table'].toggleAllSelection();
      },
      /** 库存边界限制 */
      checkQuantity(value) {
        if (!value && value !== 0) {
          this.$message.error('库存不能为空');
        } else if (!RegExp.integer.test(value) && parseInt(value) !== 0) {
          this.$message.error('请输入整数');
        } else if (!(parseInt(value) >= 0 && parseInt(value) <= 99999999)) {
          this.$message.error('请输入0 - 99999999之间的正整数');
        }
      },

      /** 分页大小发生改变 */
      handlePageSizeChange(size) {
        this.params.page_size = size;
        this.$store.dispatch('changeRecruitScrollY', 0) //翻页时把位置置顶
        this.GET_GoodsList();
      },

      /** 分页页数发生改变 */
      handlePageCurrentChange(page) {
        this.params.page_no = page;
        this.$store.dispatch('changeRecruitScrollY', 0) //翻页时把位置置顶
        this.GET_GoodsList();
      },

      /** 搜索事件触发 */
      searchEvent(data) {
        this.params = {
          ...this.params,
          keyword: data
        }
        this.params.page_no = 1;
        this.GET_GoodsList();
      },

      /** 高级搜索事件触发 */
      advancedSearchEvent() {
        this.$refs['advancedForm'].validate((valid) => {
          if (valid) {
            this.params = {
              ...this.params,
              ...this.advancedForm
            };
            this.params.page_no = 1;
            this.GET_GoodsList();
          }
        })
      },

      /** 切换上下架状态*/
      changeGoodsStatus(val) {
        delete this.params.market_enable
        if (val !== '' && val !== -1) {
          this.params = {
            ...this.params,
            market_enable: val
          }
        }
        this.params.page_no = 1;
        this.GET_GoodsList();
      },

      /** 下架*/
      handleUnderGoods(row) {
        this.$confirm('确认下架此商品, 是否继续?', '提示', { type: 'warning' }).then(() => {
          API_goods.underGoods(row.goods_id, {}).then(() => {
            this.$message.success('下架成功');
            this.GET_GoodsList();
          })
        })
      },
      /** 切换商品类型 */
      changeGoodsType(val) {
        delete this.params.goods_type;
        if (val !== '') {
          this.params = {
            ...this.params,
            goods_type: val
          }
        }
        this.params.page_no = 1;
        this.GET_GoodsList();
      },

      /** 切换分组*/
      changeGoodsCateGory(data) {
        this.advancedForm.shop_cat_path = data && Array.isArray(data) && data.length !== 0 ? `0|${data.join('|')}|` : '';
      },

      /** 显示下架原因 */
      showUnderReason(row) {
        this.isShowUnderReason = false;
        this.isShowUnderReason = true;
        this.under_reason = row.under_message;
      },

      /** 获取商品列表 */
      GET_GoodsList() {
        this.loading = true
        API_goods.getGoodsList(this.params).then(response => {
          this.loading = false
          this.pageData = {
            page_no: response.page_no,
            page_size: response.page_size,
            data_total: response.data_total
          }
          this.tableData = response.data;
          this.$nextTick(() => {
            this.resetCopyright()
          })
        })
      },
      /**
        * @date 2020/10/15
        * @author wolfMan
        * @description {添加分组}
      */
      addCat() {
        let { shop_cat_ids } = this.catForm;
        shop_cat_ids.push({});
        this.catForm.shop_cat_ids = shop_cat_ids;
      },
      /**
        * @date 2020/10/15
        * @author wolfMan
        * @description {删除分组}
      */
      deleteCat(_index) {
        let { shop_cat_ids } = this.catForm;
        shop_cat_ids.splice(_index, 1);
        this.catForm.shop_cat_ids = shop_cat_ids;
      },
      /**
        * @date 2020/10/15
        * @author wolfMan
        * @description {分组切换及时改变}
      */
      changeShopCat(val, _index) {
        let _cat = JSON.parse(JSON.stringify(this.catForm.shop_cat_ids[_index]));
        _cat.shop_cat_id = val[val.length -1];
        this.catForm.shop_cat_ids[_index] = _cat;
      },
      /**
       * @date 2021/04/20
       * @author lc
       * @description {表单重置}
       */
      resetForm(formName) {
        if (this.$refs[formName] !== undefined) {
          this.$refs[formName].resetFields();
        }
      },
      /**
        * @date 2021/04/20
        * @author lc
        * @description {显示商品分组弹层}
      */
      showCatDialog(_row, _index) {
        this.catFormType = 'single'
        this.catForm = {
          update_type: 1,
          goods_id: [],
          shop_cat_ids: []
        }
        this.resetForm('catForm');
        this.catDialog = true;
        let _catList = [];
        let _goods_id = []
        if (_row.shop_cat_item_list) {
          _catList.push(_row.shop_cat_item_list[0])
        }
        _goods_id.push(_row.goods_id)
        this.catForm = {
          update_type: 1,
          goods_id: _goods_id,
          shop_cat_ids: !_catList || !_catList.length ? [{}] : _catList
        };
      },
      /**
        * @date 2021/04/20
        * @author lc
        * @description {显示商品批量分组弹层}
      */
      setBatchUpdateShopCat() {
        this.catFormType = 'batch'
        if (!this.multipleSelection) {
          this.$message.error('请选择要分组的商品！');
          return
        }
        this.catForm = {
          update_type: 1,
          goods_id: undefined,
          shop_cat_ids: []
        }
        this.resetForm('catForm');
        this.catDialog = true;
        let _catList = []
        let goods_id = []
        this.multipleSelection.forEach((item) => {
          goods_id.push(item.goods_id)
          _catList = item.shop_cat_item_list
        });
        this.catForm = {
          update_type: 1,
          goods_id: goods_id,
          shop_cat_ids: [{}]
        };
      },
      /**
        * @date 2020/10/15
        * @author wolfMan
        * @description {保存商品分组}
      */
      catSubmit() {
        this.dialogLoading = true;
        let _form = JSON.parse(JSON.stringify(this.catForm));
        let { update_type, goods_id, shop_cat_ids } = _form;
        shop_cat_ids = shop_cat_ids.map(item => {
          return item.shop_cat_id;
        });
        let _params = {
          'shop_cat_ids': shop_cat_ids.toString(),
          'update_type': update_type,
          'goods_ids': goods_id.toString()
        }
        API_goods.batchUpdateMultiShopCat(_params).then(response => {
          this.dialogLoading = false;
          if (response && response.code !== 500) {
            this.catDialog = false;
            // let { row, index } = this.editCat;
            // row.shop_cat_items_list = response;
            // this.$set(this.tableData, index, row);
            this.$message.success(response.message);
            this.resetForm('catForm');
            this.GET_GoodsList()
          } else {
            this.$message.error('商品分组修改失败！');
          }
        }).catch((err) => {
          this.dialogLoading = false;
          this.$message.error(err);
        });
      },

      /** 发布商品*/
      publishGoods() {
        this.$router.push({ name: 'goodPublish', params: { callback: this.GET_GoodsList }})
      },
      /** 发布商品(旧版)*/
      publishGoodsOld() {
        this.$router.push({ name: 'goodPublishOld', params: { callback: this.GET_GoodsList }})
      },

      /** 跳转回收站*/
      gotoRecycle() {
        this.$router.push({ path: '/goods/recycle-station' })
      },
      openAbnormalImport() {
        this.importDialog = true;
      },
      // 取消
      handleCancel (importForm) {
        this.importDialog = false;
        this.$refs[importForm].resetFields()
      },
      excelLoadShow (content) {
        this.files = content.file;
      },
      onUploadChange() {

      },
      // 批量导入确定按钮
      submitFileForm (importForm) {
        let uploadFile = new FormData();
        uploadFile.append('file', this.files);
        API_goods.importGoodsQuantity(uploadFile).then(response => {
          console.log(response)
          this.importDialog = false;
          this.$refs[importForm].resetFields()
        })
      },

      /** 编辑商品 isdraft 商品列表1*/
      handleEditGoods(row) {
        this.$router.push({ name: 'goodPublish', params: { goodsid: row.goods_id, isdraft: 1, callback: this.GET_GoodsList }})
      },

      /** 删除商品 */
      handleDeleteGoods(row) {
        this.$confirm('确认删除此商品, 是否继续?', '提示', { type: 'warning' }).then(() => {
          const _ids = [row.goods_id].toString()
          API_goods.deleteGoods(_ids).then(() => {
            this.GET_GoodsList();
            this.$message.success('删除商品成功！');
          })
        })
      },

      /** 合并数据相同的单元格 */
      arraySpanMethod({ row, column, rowIndex, columnIndex }) {
        if (columnIndex < this.goodsStockTitle.length - 3) {
          const _row = this.concactArray[rowIndex][columnIndex]
          const _col = _row > 0 ? 1 : 0
          return {
            rowspan: _row,
            colspan: _col
          }
        }
      },

      /** 合并数据相同的单元格 */
      arraySpanMethodPrice({ row, column, rowIndex, columnIndex }) {
        if (columnIndex < this.goodsStockTitle.length - 3) {
          const _row = this.concactPriceArray[rowIndex][columnIndex]
          const _col = _row > 0 ? 1 : 0
          return {
            rowspan: _row,
            colspan: _col
          }
        }
      },

      /** 计算要合并列的位置 */
      concactArrayCom(index, item) {
        let _isMerge = false;
        /** 循环列 先循环第一列 若相同则合并 再循环第二列 依次循环 若不相同 则不合并并终止此列循环开始下一列循环 */
        let _currnetRow = [];
        for (let i = 0, _len = this.goodsStockTitle.length - 3; i < _len; i++) {
          if (this.goodsStockTitle[i].prop === 'sku_id') {
            i++
            continue
          }
          if (index > 0 && item[this.goodsStockTitle[i].prop] !== this.goodsStockData[index - 1][this.goodsStockTitle[i].prop]) {
            _currnetRow[i] = 1;
            _isMerge = true;
          } else if (index > 0 && !_isMerge) {
            _currnetRow[i] = 0
            let _count = 1;
            while (this.concactArray[index - _count][i] === 0) {
              _count++
            }
            this.concactArray[index - _count][i] += 1
          } else { // index === 0
            _currnetRow[i] = 1
          }
        }
        this.concactArray.push(_currnetRow);
      },

      /** 计算要合并列的位置 */
      concactArrayPriceCom(index, item) {
        let _isMerge = false;
        /** 循环列 先循环第一列 若相同则合并 再循环第二列 依次循环 若不相同 则不合并并终止此列循环开始下一列循环 */
        let _currnetRow = [];
        for (let i = 0, _len = this.updatePriceTitle.length - 3; i < _len; i++) {
          if (this.updatePriceTitle[i].prop === 'sku_id') {
            i++
            continue
          }
          if (index > 0 && item[this.updatePriceTitle[i].prop] !== this.updatePriceData[index - 1][this.updatePriceTitle[i].prop]) {
            _currnetRow[i] = 1;
            _isMerge = true;
          } else if (index > 0 && !_isMerge) {
            _currnetRow[i] = 0
            let _count = 1;
            while (this.concactPriceArray[index - _count][i] === 0) {
              _count++
            }
            this.concactPriceArray[index - _count][i] += 1
          } else { // index === 0
            _currnetRow[i] = 1
          }
        }
        this.concactPriceArray.push(_currnetRow);
      },

      /** 库存 */
      handleStockGoods(row) {
        this.goodsId = row.goods_id;
        this.goodsStockshow = true;
        API_goods.getGoodsStockList(row.goods_id, {}).then((response) => {
          this.goodsStockTitle = this.goodsStockData = [];
          this.goodsStocknums = response.length;
          // 构造待发货字段
          if (response.length > 1) {
            this.$nextTick(() => {
              response.forEach((key) => {
                // 构造待发货字段
                this.$set(key, 'deliver_goods_quantity', parseInt(key.quantity) - parseInt(key.enable_quantity))
                // 构造表头
                let _skus = key.spec_list.map((elem, index) => {
                  return { label: elem.spec_name, prop: 'spec_value'+ index }
                })
                this.goodsStockTitle = _skus.concat([
                  { label: '规格id', prop: 'sku_id' },
                  { label: '库存', prop: 'quantity' },
                  { label: '待发货数', prop: 'deliver_goods_quantity' }])
                // 构造表结构
                let _skuData = key.spec_list.map((elem, index) => {
                  let _map = new Map().set('spec_value'+ index, elem.spec_value)
                  let obj = Object.create(null)
                  for (let [k, v] of _map) {
                    obj[k] = v
                  }
                  return obj;
                })
                const _key = {
                  sku_id: key.sku_id,
                  quantity: key.quantity,
                  deliver_goods_quantity: key.deliver_goods_quantity
                }
                this.goodsStockData.push(Object.assign(_key, ..._skuData))
              })
              // 计算表格合并的位置
              this.concactArray = []
              this.goodsStockData.forEach((key, index) => {
                this.concactArrayCom(index, key)
              })
            })
          } else {
            response.forEach((key) => {
              // 构造待发货字段
              this.$set(key, 'deliver_goods_quantity', parseInt(key.quantity) - parseInt(key.enable_quantity));
            })
            this.goodsStockData = response[0];
          }
        })
      },

      /** 保存库存商品 */
      reserveStockGoods(type) {
        let _params = []
        let reserveType = type
        if (Array.isArray(this.goodsStockData)) {
          _params = this.goodsStockData.map((elem) => {
            return {
              quantity_count: elem.quantity,
              sku_id: elem.sku_id
            }
          })
        } else {
          _params.push({
            is_refresh: reserveType,
            quantity_count: this.goodsStockData.quantity,
            sku_id: this.goodsStockData.sku_id
          })
        }
        const _res = _params.some(key => {
          return !(parseInt(key.quantity_count) >= 0 && parseInt(key.quantity_count) < 99999999) || !/^[0-9]\d*$/.test(key.quantity_count)
        })
        if (_res) {
          this.$message.error('库存须为0 - 99999999之间的整数')
          return
        }
        API_goods.reserveStockGoods(this.goodsId, _params).then(() => {
          this.goodsStockshow = false;
          this.$message.success('库存商品保存成功');
          this.GET_GoodsList();
        })
      },

      /** 获取分销设置 */
      getDistributionSet() {
        API_goods.getDistributionSet().then(response => {
          this.distributionSet = response.message;
        })
      },

      /** 修改价格 */
      handleUpdatePriceDialog(row) {
        this.updatePriceDialog = true
        this.goodsId = row.goods_id;
        API_goods.getGoodsStockList(row.goods_id, {}).then((response) => {
          this.updatePriceTitle = this.updatePriceData = [];
          this.skuNums = response.length;
          // 构造待发货字段
          if (response.length > 1) {
            this.$nextTick(() => {
              response.forEach((key) => {
                this.updatePriceTitle = ([
                  { label: '商品规格', prop: 'spec_value' },
                  { label: '成本价', prop: 'cost' },
                  { label: '售价', prop: 'price' }])
                // 构造表结构
                let _skuData = key.spec_list.map(elem => {
                  let _map = new Map().set(elem.spec_value, elem.spec_value)
                  let obj = Object.create(null)
                  for (let [k, v] of _map) {
                    obj[k] = v
                  }
                  return obj;
                })
                const _key = {
                  sku_id: key.sku_id,
                  spec_value: key.spec_list[0].spec_value,
                  cost: key.cost,
                  price: key.price
                }
                this.updatePriceData.push(Object.assign(_key, ..._skuData))
              })
              // 计算表格合并的位置
              this.concactPriceArray = []
              this.updatePriceData.forEach((key, index) => {
                this.concactArrayPriceCom(index, key)
              })
            })
          } else {
            this.updatePriceData = {
              sku_id: response[0].sku_id,
              cost: response[0].cost,
              price: response[0].price
            };
          }
        })
      },
      // 保存修改价格
      saveBatch() {
        const _ids = this.goodsId
        let sku_list = []
        if (this.skuNums > 1) {
          this.updatePriceData.forEach((item) => {
            delete item.spec_value
            delete item['功耗']
          })
          sku_list = this.updatePriceData
        } else {
          sku_list.push(this.updatePriceData)
        }
        API_goods.updateCost(_ids, sku_list).then((res) => {
          this.updatePriceDialog = false
          this.$message.success('商品价格修改成功');
          this.GET_GoodsList();
        })
      },

      /** 返利 获取返利信息*/
      handleRebate(row) {
        setTimeout(() => { this.$refs['disRebateData'].resetFields() })
        API_goods.getDistributionInfo(row.goods_id).then(response => {
          this.isShowDisRebate = true;
          this.disRebateData = {
            /** 商品id */
            goods_id: response.goods_id || row.goods_id,

            /** 1级返利 */
            grade1Rebate: response.grade1_rebate,

            /** 2级返利 */
            grade2Rebate: response.grade2_rebate,

            inviter_rate: response.inviter_rate
          }
        })
      },

      /** 保存分销返利信息 */
      reserveDisSet(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            API_goods.setDistributionInfo(this.disRebateData).then(() => {
              this.isShowDisRebate = false;
              this.$message.success('当前商品分销返利金额修改成功');
            })
          }
        })
      },

      /** 保存批量设置分销佣金 */
      batDataSet(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let goods_ids = this.selectedDatas.map((item) => {
              return item.goods_id;
            });
            API_goods.batchEditGoods(goods_ids.toString(), this.setbateData).then((res) => {
              this.isShowSetbate = false;
              this.$message.success('设置成功');
              this.$refs[formName].resetFields();
            }).catch((err) => {
              this.$message.warning(err);
            })
          }
        })
      },
      cansleBatSet(formName) {
        this.isShowSetbate = false;
        this.$refs[formName].resetFields();
      },

      /**
        * @date 2020/11/28
        * @author luochegn
        * @description {批量设置佣金}
      */
      setBatchGoods() {
        if (!this.multipleSelection.length) {
          this.$message.warning(`请选择需要设置的商品！`)
          return
        }
        this.isShowSetbate = true;
      },

      /**
        * @date 2020/11/28
        * @author luochegn
        * @description {复制商品}
      */
      copyBatchGoods() {
        if (!this.multipleSelection.length) {
          this.$message.warning(`请选择需要复制的商品！`)
          return
        }
        let _selectIds = []
        let _canNext = true
        for (let item of this.multipleSelection) {
          _selectIds.push(item.goods_id)
        }
        let params = {
          goodsIds: _selectIds.toString()
        }
        this.$confirm(`已选中${_selectIds.length}个商品，确认复制到本店铺吗？`, '商品复制提示', { type: 'warning' }).then(() => {
          API_goods.copyGoods(params).then((res) => {
            this.$message.success(res.message);
            this.GET_GoodsList();
          }).catch((err) => {
            this.$message.error(err.message);
          })
        })
      },

      /**
        * @date 2020/05/14
        * @author wolfMan
        * @description {批量上/下架商品 _type(0: 上架；1: 下架)}
      */
      batchGoods(_type) {
        let _typeText = _type === 1 ? '下' : '上'
        if (!this.multipleSelection.length) {
          this.$message.warning(`请选择需要${_typeText}架的商品！`)
          return
        }
        let _selectIds = []
        let _canNext = true
        for (let item of this.multipleSelection) {
          let _downDisabled = _type === 0 && item.market_enable === 1
          let _upDisabled = _type === 1 && item.market_enable === 0
          if (_downDisabled || _upDisabled) {
            _canNext = false
            break
          }
          _selectIds.push(item.goods_id)
        }
        if (!_canNext) {
          this.$message.warning(`你选择的商品中存在已${_typeText}架商品，已${_typeText}架商品不能进行批量${_typeText}架操作！`)
          return
        }
        if (_type === 1) {
          this.$confirm(`已选中${_selectIds.length}个商品，下架后将不可售卖，确定要下架吗？`, '商品批量下架提示', { type: 'warning' }).then(() => {
            API_goods.underGoods(_selectIds.toString(), {}).then(() => {
              this.$message.success('批量下架成功');
              this.GET_GoodsList();
            })
          })
        } else {
          this.$confirm(`已选中${_selectIds.length}个商品，确定要上架吗？`, '商品批量上架提示', { type: 'warning' }).then(() => {
            API_goods.upsGoods(_selectIds.toString(), {}).then(() => {
              this.$message.success('批量上架成功');
              this.GET_GoodsList();
            })
          })
        }
      }
    }
  }
</script>

<style type="text/scss" lang="scss" scoped>
  /deep/ div.toolbar {
    height: 70px;
    padding: 20px 0;
  }
  /deep/ .price-sku .toolbar {
    height: auto;
    padding: 0;
  }

  /deep/ .el-table {
    width: 100%;
    overflow-x: scroll;
    & td:not(.is-left) {
      text-align: center;
    }
  }

  /deep/ .price-sku .el-table {
    overflow-x: auto;
  }

  .inner-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 1200px;
    justify-content: space-between;
    align-items: center;
  }

  /deep/ .pop-sku {
    .toolbar {
      display: none;
    }
    .el-dialog__body {
      .el-table {
        border: 1px solid #e5e5e5;
      }
    }
    .el-table__body-wrapper {
      max-height: 400px;
      overflow-y: scroll;
    }
  }

  .batch_f {
    margin-right: 10px;
    font-size: 14px;
    color: #409EFF;
  }

  .batch_f:hover {
    text-decoration: underline;
    cursor: pointer;
  }

  .toolbar-search {
    width: 20%;
  }

  div.toolbar-btns {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    .el-button {
      margin-right: 10px;
      & + .el-button {
        margin-left: 0;
      }
    }
    div {
      span {
        display: inline-block;
        font-size: 14px;
        color: #606266;
      }
    }
    .conditions {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      justify-content: flex-start;
      align-items: center;
      min-width: 24.5%;
      .choose-machine {
        width: 60%;
      }
    }
  }

  .goods-image {
    width: 50px;
    height: 50px;
  }

  /deep/ div.cell {
    overflow:hidden;

    text-overflow:ellipsis;

    display:-webkit-box;

    -webkit-box-orient:vertical;

    -webkit-line-clamp:2;
  }
  /*下架原因*/
  .under-reason {
    color: red;
    cursor: pointer;
  }
  .goodsSource {
    color: #999999;
  }

  .dialog-coding-import {
    .coding-import {
      padding: 20px 30px;
      text-align: center;
    }
  }
.top-search{
  display: flex;
  flex-flow: row nowrap;
    .conditions {
      margin-right: 10px;
      font-size: 12px;
    }
}
.greenText {
  color: green;
}
.redText {
  color: red;
}
.advancedForm .el-cascader {
  width: 100%;
}
.footerBtn {
  text-align: center;
}
/deep/ ::-webkit-scrollbar-track-piece { //滚动条凹槽的颜色，还可以设置边框属性
  background-color:#f8f8f8;
}
/deep/ ::-webkit-scrollbar {//滚动条的宽度
  width:9px;
  height:9px;
}
/deep/ ::-webkit-scrollbar-thumb {//滚动条的设置
  background-color:#dddddd;
  background-clip:padding-box;
  min-height:28px;
}
/deep/ ::-webkit-scrollbar-thumb:hover {
  background-color:#bbb;
}

  /deep/ .el-table__body {
    .el-form-item {
      margin-bottom: 0;
    }

    .el-input-group__prepend {
      padding: 0 12px;
    }

    .el-input-group__append {
      padding: 0 10px;
    }

    .el-form-item__content {
      position: static;
    }

    .el-form-item__error {
      display: inline-block;
      margin-top: -20px;
      margin-left: 12px;
    }

    .cat-show-box {
      display: inline-block;
      position: relative;
      padding-right: 26px;
      max-width: 100%;
      .cat-show-item {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .cat-edit {
        position: absolute;
        top: 50%;
        right: 0;
        margin-top: -8px;
        line-height: 0;
        .table-edit {
          display: inline-block;
          width: 16px;
          height: 16px;
          line-height: 16px;
          color: #409EFF;
          font-size: 16px;
        }
        &:hover {
          text-decoration: underline;
        }
      }
    }

    .show-cat-name {
      display: inline-block;
      position: relative;
      padding-right: 20px;

      .cat-name {
        display: block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        line-height: 14px;
      }

      .table-edit {
        display: inline-block;
        position: absolute;
        top: 50%;
        right: 0;
        margin-top: -8px;
        width: 16px;
        height: 16px;
        line-height: 16px;
        font-size: 16px;
      }
    }

    .el-icon-edit-outline {
      cursor: pointer;
    }
  }

  .color-success {
    color: #30B08F !important;
  }

  .color-red {
    color: red !important;
  }
</style>
